package com.org.manhu.chargehelper.download;

import java.util.HashMap;
import java.util.Map;

/**
 * @文件名：DownloadManager.java
 * @包名：com.org.manhu.chargehelper.download
 * @作者：李朋辉 @QQ：892839211
 * @创建时间：2015年3月4日 下午5:00:37
 *
 * @描述：
 */
public class DownloadManager {

	private static DownloadManager instance;
	private Map<String, DownloadTask> taskList;
	private Map<String, Boolean> isTaskPause;

	private DownloadManager() {
		taskList = new HashMap<String, DownloadTask>();
		isTaskPause = new HashMap<String, Boolean>();
	}

	public static DownloadManager getInstance() {
		if (instance == null) {
			instance = new DownloadManager();
		}
		return instance;
	}

	public void add2TaskList(String downUrl, DownloadTask task) {
		taskList.put(downUrl, task);
	}

	public void updateTaskState(String downUrl, Boolean isPause) {
		isTaskPause.put(downUrl, isPause);
	}

	public DownloadTask getDownloadTask(String downUrl) {
		return taskList.get(downUrl);
	}

	public boolean isTaskPause(String downUrl) {
		return isTaskPause.get(downUrl);
	}

	public void deleteTask(String downUrl) {
		taskList.remove(downUrl);
		isTaskPause.remove(downUrl);
	}

}
